import 'package:my_blog_flutter/app/modules/home_detail/models/comment_entity.dart';
import 'package:my_blog_flutter/generated/json/base/json_convert_content.dart';


CommentEntity $CommentEntityFromJson(Map<String, dynamic> json) {
  final CommentEntity commentEntity = CommentEntity();
  final int? code = jsonConvert.convert<int>(json['code']);
  if (code != null) {
    commentEntity.code = code;
  }
  final String? message = jsonConvert.convert<String>(json['message']);
  if (message != null) {
    commentEntity.message = message;
  }
  final CommentData? data = jsonConvert.convert<CommentData>(json['data']);
  if (data != null) {
    commentEntity.data = data;
  }
  final int? timestamp = jsonConvert.convert<int>(json['timestamp']);
  if (timestamp != null) {
    commentEntity.timestamp = timestamp;
  }
  return commentEntity;
}

Map<String, dynamic> $CommentEntityToJson(CommentEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['code'] = entity.code;
  data['message'] = entity.message;
  data['data'] = entity.data?.toJson();
  data['timestamp'] = entity.timestamp;
  return data;
}

extension CommentEntityExtension on CommentEntity {
  CommentEntity copyWith({
    int? code,
    String? message,
    CommentData? data,
    int? timestamp,
  }) {
    return CommentEntity()
      ..code = code ?? this.code
      ..message = message ?? this.message
      ..data = data ?? this.data
      ..timestamp = timestamp ?? this.timestamp;
  }
}

CommentData $CommentDataFromJson(Map<String, dynamic> json) {
  final CommentData commentData = CommentData();
  final int? totalCount = jsonConvert.convert<int>(json['totalCount']);
  if (totalCount != null) {
    commentData.totalCount = totalCount;
  }
  final List<CommentDataList>? list = (json['list'] as List<dynamic>?)
      ?.map(
          (e) => jsonConvert.convert<CommentDataList>(e) as CommentDataList)
      .toList();
  if (list != null) {
    commentData.list = list;
  }
  return commentData;
}

Map<String, dynamic> $CommentDataToJson(CommentData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['totalCount'] = entity.totalCount;
  data['list'] = entity.list?.map((v) => v.toJson()).toList();
  return data;
}

extension CommentDataExtension on CommentData {
  CommentData copyWith({
    int? totalCount,
    List<CommentDataList>? list,
  }) {
    return CommentData()
      ..totalCount = totalCount ?? this.totalCount
      ..list = list ?? this.list;
  }
}

CommentDataList $CommentDataListFromJson(Map<String, dynamic> json) {
  final CommentDataList commentDataList = CommentDataList();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    commentDataList.id = id;
  }
  final String? userName = jsonConvert.convert<String>(json['userName']);
  if (userName != null) {
    commentDataList.userName = userName;
  }
  final String? content = jsonConvert.convert<String>(json['content']);
  if (content != null) {
    commentDataList.content = content;
  }
  final String? createTime = jsonConvert.convert<String>(json['createTime']);
  if (createTime != null) {
    commentDataList.createTime = createTime;
  }
  return commentDataList;
}

Map<String, dynamic> $CommentDataListToJson(CommentDataList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['userName'] = entity.userName;
  data['content'] = entity.content;
  data['createTime'] = entity.createTime;
  return data;
}

extension CommentDataListExtension on CommentDataList {
  CommentDataList copyWith({
    int? id,
    String? userName,
    String? content,
    String? createTime,
  }) {
    return CommentDataList()
      ..id = id ?? this.id
      ..userName = userName ?? this.userName
      ..content = content ?? this.content
      ..createTime = createTime ?? this.createTime;
  }
}